/*Copyright (C) 2009 - 2011 MASSART GAUTHIER

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

#include "../headers.h"


void rev_affichage(short matrice[65], const char *message, const char *nom_joueur, short choix, short joueur) {
	short y = 5, x = x_begin_center(64), i = 0, j = 0, jeton = 1;

	CSLP_Color(COLOR_BLUE, COLOR_BLACK);
	for(i = 0; i != 8; i++) {
		for(j = 0; j != 8; j++) {
			if(matrice[jeton] == '1') {
				CSLP_ColorBG(COLOR_YELLOW);
			}
			else if(matrice[jeton] == '2') {
				CSLP_ColorBG(COLOR_RED);
			}
			else if(matrice[jeton] == '3') {
				CSLP_ColorBG(COLOR_GREEN);
			}
			else {
				CSLP_ColorBG(COLOR_BLACK);
			}
			mvaddstr(y, x,     "███▀▀███");
			mvaddstr(y + 1, x, "█▀");
			if(jeton == choix) {
				if(joueur == 1) {
					CSLP_ColorText(COLOR_YELLOW);
				}
				else {
					CSLP_ColorText(COLOR_RED);
				}
				addstr("▒▒▒▒");
				CSLP_ColorText(COLOR_BLUE);
			}
			else {
				addstr("    ");
			}
			addstr("▀█");
			mvaddstr(y + 2, x, "█▄");
			if(jeton == choix) {
				if(joueur == 1) {
					CSLP_ColorText(COLOR_YELLOW);
				}
				else {
					CSLP_ColorText(COLOR_RED);
				}
				addstr("▒▒▒▒");
				CSLP_ColorText(COLOR_BLUE);
			}
			else {
				addstr("    ");
			}
			addstr("▄█");
			mvaddstr(y + 3, x, "███▄▄███");
			CSLP_ColorBG(COLOR_BLACK);
			x += 8;
			jeton++;
		}
		y += 4;
		x = x_begin_center(64);
	}

	if(choix == 0) {
		CSLP_Color(COLOR_WHITE, COLOR_CYAN);
	}
	else {
		CSLP_ColorText(COLOR_WHITE);
	}

	mvaddstr(34, 5, "┌─────────┐");
	mvaddstr(35, 5, "│ QUITTER │");
	mvaddstr(36, 5, "└─────────┘");
	CSLP_Color(COLOR_BLUE, COLOR_BLACK);

	rev_afficher_message(message, nom_joueur, joueur);
	refresh();
}

void rev_afficher_message(const char *message, const char *nom_joueur, short joueur) {
	save_cursor_pos();
	move(38, 0);
	if(joueur == 1) {
		CSLP_Color(COLOR_YELLOW, COLOR_BLACK);
	}
	else {
		CSLP_Color(COLOR_RED, COLOR_BLACK);
	}
	clear_line();
	afficher_centre(nom_joueur);
	CSLP_ColorText(CT);
	clear_line();
	afficher_centre(message);
	restore_cursor_pos();
	CSLP_ColorText(COLOR_WHITE);
}
